﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using HIWSystem.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HIWSystem.ViewModel
{
    public class InputBoxViewModel:ViewModelBase
    {
        #region 属性
        private string inputContent;
        /// <summary>
        /// 输入的内容
        /// </summary>
        public string InputContent
        {
            get { return inputContent; }
            set { inputContent = value; this.RaisePropertyChanged(() => InputContent); }
        }
        //Header
        private string header="请输入内容";
        /// <summary>
        /// 输入的内容
        /// </summary>
        public string Header
        {
            get { return header; }
            set { header = value; this.RaisePropertyChanged(() => Header); }
        }
        #endregion

        #region 命令
        //ConfirmCmd
        private RelayCommand confirmCmd;

        public RelayCommand ConfirmCmd
        {
            get
            {
                if (confirmCmd == null)
                {
                    confirmCmd = new RelayCommand(Confrim);
                }
                return confirmCmd;
            }
            set { confirmCmd = value; }
        }
        private RelayCommand cancelCmd;

        public RelayCommand CancelCmd
        {
            get
            {
                if (cancelCmd == null)
                {
                    cancelCmd = new RelayCommand(Cancel);
                }
                return cancelCmd;
            }
            set { cancelCmd = value; }
        }
        #endregion

        #region 方法
        //点击取消
        private void Cancel()
        {
            Messenger.Default.Send<string>("", "InputBox");
            ViewManager.Close("InputBox");
        }

        //点击确认
        private void Confrim()
        {
            Messenger.Default.Send<string>((InputContent ?? "0"), "InputBox");
            InputContent = "";
            ViewManager.Close("InputBox");
        }
        #endregion
    }
}
